package com.ymtms.arrivalofgoods.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ymtms.arrivalofgoods.bo.GridResult;
import com.ymtms.arrivalofgoods.dao.BillDetailedMapper;
import com.ymtms.arrivalofgoods.pojo.BillDetailed;
import com.ymtms.arrivalofgoods.service.BillDetailedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BillDetailedServiceImpl implements BillDetailedService {
    @Autowired
    BillDetailedMapper billDetailedMapper;
    @Override
    public List<BillDetailed> showAllBillDetailed() {
        List <BillDetailed> result = billDetailedMapper.selectAll();
        return result;
    }

    @Override
    public GridResult<BillDetailed> showBillDetailedByCondition(Integer currentPage, Integer pageSize, String condition) {
        PageHelper.startPage(currentPage,pageSize);
        List<BillDetailed> result =billDetailedMapper.queryDetailedByCondition(condition);
        PageInfo<BillDetailed> pageInfo = new PageInfo<>(result);
        GridResult<BillDetailed> gridResult = new GridResult<>();
        gridResult.setCount(pageInfo.getTotal());
        gridResult.setData(result);
        return gridResult;
    }
}
